<?php
/**
 * User: Allen
 * Date: 15-12-01
 * 网点控制器
 */

class Area extends WX_Controller{
	
	public function __construct(){
		parent::__construct();
		$this->load->model('area_model');
	}
	/**
	 * @brief 获取联动城市
	 * @param Null
	 * @par 2015/12/01 Ver 1.00 Created by Allen
	 */
	public function city() {
		$id = $this->uri->segment(4);
		$city_list = $this->area_model->getArealist(array('parentno'=>$id,'arealevel'=>2));
		$county_list = $this->area_model->getArealist(array('parentno'=>$city_list[0]['areano'],'arealevel'=>3));
		$city ='';
		$county = '';
		foreach($city_list as $value) {
			$city .= ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
		}
		foreach($county_list as $value) {
			$county .= ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
		}
		$data['city'] = $city;
		$data['county'] = $county;
		echo json_encode($data);
	}
	
	/**
	 * @brief 获取联动区域
	 * @param Null
	 * @par 2015/12/01 Ver 1.00 Created by Allen
	 */
	public function county() {
		$id = $this->uri->segment(4);
		$county_list = $this->area_model->getArealist(array('parentno'=>$id,'arealevel'=>3));
		$county = '';
		foreach($county_list as $value) {
			$county .= ' <option value="'.$value['areano'].','.$value['areaname'].'">'.$value['areaname'].'</option>';
		}
		$data['county'] = $county;
		echo json_encode($data);
	}
	
	
}
?>